package com.atguigu.democustomer230201.serivce.impl;

import com.atguigu.democustomer230201.bean.Customer;
import com.atguigu.democustomer230201.mapper.CustomerMapper;
import com.atguigu.democustomer230201.serivce.CustomerService;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@DS("test")
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper,Customer> implements CustomerService {

    @Autowired
    CustomerMapper customerMapper;

    @Override
    public String getCustomerByNameWithAge(Integer age, String name) {
        System.out.println("2222222");
        //利用Mapper中Mybatis通过sql查询数据
        Customer customer = customerMapper.selectCustomerByNameWithAge(name, age);
        return customer.toString();
    }

    @Override
    public String getCustomerById(String id) {
        Customer customer = customerMapper.selectCustomerById(id);
        return customer.toString();
    }

    @Override
    @DS("test")
    public void saveCustomer(Customer customer) {
        //自己定义的方法
        customerMapper.insertCustomer(customer);
        //Mybatis-Plus方法
//        customerMapper.insert(customer);
    }
}
